package com.example.handler;

import java.util.ArrayList;

import android.content.Context;

import com.example.callback.OnDataReceiver;
import com.example.database.DatabaseHelper;
import com.example.item.ItemList;

public class ContactHandler {
	private OnDataReceiver listener;
	DatabaseHelper db;
	public Context context;

	public ContactHandler() {
	}

	public ContactHandler(Context context) {
		this.context = context;
	}

	public void getAllContact() {
		Thread thread = new Thread(getAllContact);
		thread.start();
	}

	Runnable getAllContact = new Runnable() {

		@Override
		public void run() {
			db = new DatabaseHelper(context);
			ArrayList<ItemList> list = db.getAllContact();
			if(list!=null){
				listener.OnDataContact(list);
			}
		}
	};

	public void setOnDataReceiverListener(OnDataReceiver listener) {
		this.listener = listener;
	}
}
